#ifndef PLAYER_HH
#define PLAYER_HH

#include "ICharacter.hh"
#include "Inventory.hh"
#include "Item.hh"
#include "clearScreen.hh"
#include <vector>
#include <iostream>
#include <memory>

// The Player class represents the main character controlled by the user. 
// It inherits from ICharacter and manages player stats, actions, combat 
// capabilities, inventory, and equipment.

class Player: public ICharacter{
    private:
        std::string name;
        unsigned health;
        unsigned MaxHealth;
        unsigned attackPower;
        unsigned defensePower;
        unsigned AP;//行动点
        unsigned maxAP;
        unsigned gold;
        Inventory inventory;//道具系统

        //装备系统,更改为智能指针
        std::unique_ptr<Item> equippedWeapon;
        std::unique_ptr<Item> equippedArmor;

    public:
        Player(const std::string& name, unsigned health, unsigned MaxHealth, unsigned attack, unsigned defense, unsigned AP, unsigned gold);
        Player()=default;
        // Player(const Player& other)=default;
        // Player& operator=(const Player& other)=default;  //这两个函数因为使用智能指针无法复制或赋值
        //These two functions cannot copy or assign this class because they use smart pointers.
        
        // 基本信息接口
        std::string getName() const override;
        void setHealth(unsigned amount);
        void setmaxHealth(unsigned amount);
        void setmaxAP(unsigned amount);
        void setAttack(unsigned amount);
        void setDefense(unsigned amount);
        void useAP();
        unsigned getHealth() const override;
        unsigned getMaxHealth() const;
        unsigned getAttack() const override;
        unsigned getDefense() const override;
        unsigned getmaxAP() const;
        std::string toString() const override;

        // 战斗与状态
        bool isAlive() const override;
        void attack(ICharacter& target) override;

        // 操作符重载
        ICharacter& operator-=(unsigned damage) override;
        ICharacter& operator*(ICharacter& target) override;

        //Player专属
        void useItem();// 玩家从背包中使用道具
        void addItem(const Item& item); // 玩家获得道具
        void showInventory() const ;
        bool tryEscape();              // 尝试逃跑，返回是否成功
        void displayStatus() const; 
        void addGold(unsigned int gold);
        void spendGold(unsigned  int gold);
        unsigned getGold() const;
        unsigned getAP() const;
        void setAP(unsigned int AP);
        void equipItem(const Item& item);
        void restoreHealth(unsigned int amount);
        void decreaseMaxHP(int amount);

        // 访问装备系统
        Item* getEquippedWeapon() const;
        Item* getEquippedArmor() const;
};



#endif